<div class="layui-form" action="">

    <div class="layui-form-item">
        <label class="layui-form-label">支付金额</label>
        <div class="layui-input-block">
            <input type="number" id="user" lay-verify="required" placeholder="请输入金额" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">支付方式</label>
        <div class="layui-input-block">
            <input type="number" id="pass" lay-verify="required" placeholder="输入代码1（微信）；2（支付宝）" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">通讯密钥</label>
        <div class="layui-input-block">
            <input type="text" id="key" lay-verify="required" placeholder="请输入通讯密钥" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item" style="text-align: right;">
        <button class="layui-btn" onclick="save()">支付</button>
    </div>



    <!--<div class="layui-form-item layui-form-text">-->
        <!--<label class="layui-form-label">设置进入网站的提示</label>-->
        <!--<div class="layui-input-block">-->
            <!--<textarea placeholder="请输入公告内容" id="xz" class="layui-textarea"></textarea>-->
        <!--</div>-->
    <!--</div>-->
    <!--<div class="layui-form-item">-->
        <!--<button class="layui-btn" onclick="editxz()">保存</button>-->
    <!--</div>-->
</div>
<script type="text/javascript" src="js/md5.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/json2/20160511/json2.js"></script>

<script>
    console.log("setinfo已经执行");
    function setInfo(){

        $.post("/admin/getSettings",function (data) {
                        console.log(data);
                        if (data.code==1){
                            $("#key").val(data.data.key);
                            document.getElementById("phoneContent").value=data.data.key;
                        }
                    });
    }

setInfo();
    function save() {
        var price = $("#user").val();
        var type = $("#pass").val();
        var key = $("#key").val();
        var payId =new Date().getTime();
        var sign = hex_md5(payId+type+price+key);
<!--        console.log(key);-->

        if (price == ""){
            layer.msg("请输入支付金额");
            return;
        }
        if (type == ""){
            layer.msg("请输入支付方式");
            return;
        }
        if (key == ""){
            layer.msg("请输入通讯密钥");
            return;
        }

        $.post("/createOrder","payId="+payId+"&type="+type+"&price="+price+"&sign="+sign+"&isHtml="+0+"&phone="+15516111415,function (data) {
            data1=JSON.parse(data);
            console.log(data1);
            if (data1["code"]==1){
                console.log("进入跳转");
                window.location.href="/payPage/pay.html?orderId="+data1["data"]["orderId"]+;
                console.log("完成跳转");

            }
        });
    }
</script>